package jenry.xml;

import java.io.StringReader;

import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import jenry.utils.HttpDownloader;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Gan_XML extends Activity {
    Button start = null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        start = (Button)findViewById(R.id.start);
        start.setOnClickListener(new startListener());
    }
    
    class startListener implements OnClickListener{

		@Override
		public void onClick(View v) {
			HttpDownloader hd = new HttpDownloader();
			String resultStr = hd.download("http://192.168.1.106:8088/test1/voa1500/test.xml","voa/","test.xml");
			System.out.println(resultStr);
			try{
				SAXParserFactory factory = SAXParserFactory.newInstance();
				XMLReader reader = factory.newSAXParser().getXMLReader();
				reader.setContentHandler(new MyContentHandler());
				reader.parse(new InputSource(new StringReader(resultStr)));
			}
			catch(Exception e){
				e.printStackTrace();
			}
		}
    	
    }
}